
<!DOCTYPE HTML>
<html lang="zh-hans" >
    <head>
        <meta charset="UTF-8">
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <title>Redis · My Study Note</title>
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <meta name="description" content="">
        <meta name="generator" content="GitBook 3.2.3">
        <meta name="author" content="yanglonglong">
        
        
    
    <link rel="stylesheet" href="../gitbook/style.css">

    
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-code/plugin.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-search-pro/search.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-toggle-chapters/toggle.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-flexible-alerts/style.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-highlight/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-fontsettings/website.css">
                
            
                
                <link rel="stylesheet" href="../gitbook/gitbook-plugin-theme-comscore/test.css">
                
            
        

    

    
        
    
        
    
        
    
        
    
        
    
        
    

        
    
    
    <meta name="HandheldFriendly" content="true"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
    <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">

    
    <link rel="next" href="../数据结构知识/" />
    
    
    <link rel="prev" href="MySQL.html" />
    

    </head>
    <body>
        
<div class="book">
    <div class="book-summary">
        
            
<div id="book-search-input" role="search">
    <input type="text" placeholder="输入并搜索" />
</div>

            
                <nav role="navigation">
                


<ul class="summary">
    
    
    
        
        <li>
            <a href="https://www.yangllong.top/" target="_blank" class="custom-link">My Blog</a>
        </li>
    
    

    
    <li class="divider"></li>
    

    
        
        
    
        <li class="chapter " data-level="1.1" data-path="../">
            
                <a href="../">
            
                    
                    Introduction
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="../Linux相关/">
            
                <a href="../Linux相关/">
            
                    
                    Linux相关
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.2.1" data-path="../Linux相关/make工具的使用.html">
            
                <a href="../Linux相关/make工具的使用.html">
            
                    
                    Make工具的使用
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="../springboot/">
            
                <a href="../springboot/">
            
                    
                    Springboot
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.3.1" data-path="../springboot/springboot一些遇到的问题.html">
            
                <a href="../springboot/springboot一些遇到的问题.html">
            
                    
                    Springboot一些遇到的问题
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="../vue/">
            
                <a href="../vue/">
            
                    
                    Vue
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.4.1" data-path="../vue/vue+ssm跨域问题.html">
            
                <a href="../vue/vue+ssm跨域问题.html">
            
                    
                    Vue+Ssm跨域问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.2" data-path="../vue/vue-cli3.html">
            
                <a href="../vue/vue-cli3.html">
            
                    
                    Vue Cli3
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.4.3" data-path="../vue/安装vue.html">
            
                <a href="../vue/安装vue.html">
            
                    
                    安装Vue
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="../其他/">
            
                <a href="../其他/">
            
                    
                    其他
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.5.1" data-path="../其他/分布式系统.html">
            
                <a href="../其他/分布式系统.html">
            
                    
                    分布式系统
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.2" data-path="../其他/图解http.html">
            
                <a href="../其他/图解http.html">
            
                    
                    图解Http
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.3" data-path="../其他/消息队列.html">
            
                <a href="../其他/消息队列.html">
            
                    
                    消息队列
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.5.4" data-path="../其他/爬虫.html">
            
                <a href="../其他/爬虫.html">
            
                    
                    爬虫
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="../刷题/">
            
                <a href="../刷题/">
            
                    
                    刷题
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.1" data-path="../刷题/NOJ.html">
            
                <a href="../刷题/NOJ.html">
            
                    
                    NOJ
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.2" data-path="../刷题/leetcode/">
            
                <a href="../刷题/leetcode/">
            
                    
                    Leetcode
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3" data-path="../刷题/leetcode/107简单题.html">
            
                <a href="../刷题/leetcode/107简单题.html">
            
                    
                    107简单题
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.6.3.1" data-path="../刷题/leetcode/2两数相加.html">
            
                <a href="../刷题/leetcode/2两数相加.html">
            
                    
                    2两数相加
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.3.2" data-path="../刷题/leetcode/3无重复子串的最大长度.html">
            
                <a href="../刷题/leetcode/3无重复子串的最大长度.html">
            
                    
                    3无重复子串的最大长度
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.6.4" data-path="../刷题/扇贝杯csdn.html">
            
                <a href="../刷题/扇贝杯csdn.html">
            
                    
                    扇贝杯Csdn
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.5" data-path="../刷题/排序算法.html">
            
                <a href="../刷题/排序算法.html">
            
                    
                    排序算法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.6" data-path="../刷题/蓝桥杯.html">
            
                <a href="../刷题/蓝桥杯.html">
            
                    
                    蓝桥杯
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.7" data-path="../刷题/蓝桥杯热身赛.html">
            
                <a href="../刷题/蓝桥杯热身赛.html">
            
                    
                    蓝桥杯热身赛
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.6.8" data-path="../刷题/计算机等级考试(C语言">
            
                <span>
            
                    
                    计算机等级考试(C语言)
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.7" data-path="../博客/">
            
                <a href="../博客/">
            
                    
                    博客
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.7.1" data-path="../博客/next主题配置.html">
            
                <a href="../博客/next主题配置.html">
            
                    
                    Next主题配置
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.7.2" data-path="../博客/一些问题的记录.html">
            
                <a href="../博客/一些问题的记录.html">
            
                    
                    一些问题的记录
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.8" data-path="../学习java/">
            
                <a href="../学习java/">
            
                    
                    学习Java
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.8.1" data-path="../学习java/AQS.html">
            
                <a href="../学习java/AQS.html">
            
                    
                    AQS
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.2" data-path="../学习java/HashMap的简单实现.html">
            
                <a href="../学习java/HashMap的简单实现.html">
            
                    
                    HashMap的简单实现
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.3" data-path="../学习java/JavaByteCode.html">
            
                <a href="../学习java/JavaByteCode.html">
            
                    
                    JavaByteCode
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.4" data-path="../学习java/Java基础.html">
            
                <a href="../学习java/Java基础.html">
            
                    
                    Java基础
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.5" data-path="../学习java/Java多线程.html">
            
                <a href="../学习java/Java多线程.html">
            
                    
                    Java多线程
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.6" data-path="../学习java/Java多线程并发.html">
            
                <a href="../学习java/Java多线程并发.html">
            
                    
                    Java多线程并发
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.7" data-path="../学习java/Java爬虫.html">
            
                <a href="../学习java/Java爬虫.html">
            
                    
                    Java爬虫
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.8" data-path="../学习java/Java集合.html">
            
                <a href="../学习java/Java集合.html">
            
                    
                    Java集合
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.9" data-path="../学习java/java常用类.html">
            
                <a href="../学习java/java常用类.html">
            
                    
                    Java常用类
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.10" data-path="../学习java/jvm.html">
            
                <a href="../学习java/jvm.html">
            
                    
                    Jvm
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.11" data-path="../学习java/noifelse.html">
            
                <a href="../学习java/noifelse.html">
            
                    
                    Noifelse
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.12" data-path="../学习java/socket.html">
            
                <a href="../学习java/socket.html">
            
                    
                    Socket
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.13" data-path="../学习java/一些Java方法.html">
            
                <a href="../学习java/一些Java方法.html">
            
                    
                    一些Java方法
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.14" data-path="../学习java/一些其他人写的博客.html">
            
                <a href="../学习java/一些其他人写的博客.html">
            
                    
                    一些其他人写的博客
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.15" data-path="../学习java/硬核空间.html">
            
                <a href="../学习java/硬核空间.html">
            
                    
                    硬核空间
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.16" data-path="../学习java/遇到的问题.html">
            
                <a href="../学习java/遇到的问题.html">
            
                    
                    遇到的问题
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.8.17" data-path="../学习java/阻塞队列.html">
            
                <a href="../学习java/阻塞队列.html">
            
                    
                    阻塞队列
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.9" data-path="../安卓开发/">
            
                <a href="../安卓开发/">
            
                    
                    安卓开发
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.9.1" data-path="../安卓开发/First App.html">
            
                <a href="../安卓开发/First App.html">
            
                    
                    First App
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.9.2" data-path="../安卓开发/problems.html">
            
                <a href="../安卓开发/problems.html">
            
                    
                    Problems
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.10" data-path="../工具/">
            
                <a href="../工具/">
            
                    
                    工具
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.10.1" data-path="../工具/IDEA.html">
            
                <a href="../工具/IDEA.html">
            
                    
                    IDEA
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.2" data-path="../工具/docker.html">
            
                <a href="../工具/docker.html">
            
                    
                    Docker
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.10.3" data-path="../工具/github.html">
            
                <a href="../工具/github.html">
            
                    
                    Github
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.11" data-path="./">
            
                <a href="./">
            
                    
                    数据库
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.11.1" data-path="MVCC.html">
            
                <a href="MVCC.html">
            
                    
                    MVCC
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.11.2" data-path="MySQL.html">
            
                <a href="MySQL.html">
            
                    
                    MySQL
            
                </a>
            

            
        </li>
    
        <li class="chapter active" data-level="1.11.3" data-path="Redis.html">
            
                <a href="Redis.html">
            
                    
                    Redis
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.12" data-path="../数据结构知识/">
            
                <a href="../数据结构知识/">
            
                    
                    数据结构知识
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.12.1" data-path="../数据结构知识/大话数据结构笔记1.html">
            
                <a href="../数据结构知识/大话数据结构笔记1.html">
            
                    
                    大话数据结构笔记1
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.12.2" data-path="../数据结构知识/大话数据结构笔记2.html">
            
                <a href="../数据结构知识/大话数据结构笔记2.html">
            
                    
                    大话数据结构笔记2
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="1.13" data-path="../面试笔试/">
            
                <a href="../面试笔试/">
            
                    
                    面试笔试
            
                </a>
            

            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.13.1" data-path="../面试笔试/字节跳动5月11日笔试.html">
            
                <a href="../面试笔试/字节跳动5月11日笔试.html">
            
                    
                    字节跳动5月11日笔试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.2" data-path="../面试笔试/阿里3月23日笔试.html">
            
                <a href="../面试笔试/阿里3月23日笔试.html">
            
                    
                    阿里3月23日笔试
            
                </a>
            

            
        </li>
    
        <li class="chapter " data-level="1.13.3" data-path="../面试笔试/面试突击.html">
            
                <a href="../面试笔试/面试突击.html">
            
                    
                    面试突击
            
                </a>
            

            
        </li>
    

            </ul>
            
        </li>
    

    

    <li class="divider"></li>

    <li>
        <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
            本书使用 GitBook 发布
        </a>
    </li>
</ul>


                </nav>
            
        
    </div>

    <div class="book-body">
        
            <div class="body-inner">
                
                    

<div class="book-header" role="navigation">
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href=".." >Redis</a>
    </h1>
</div>




                    <div class="page-wrapper" tabindex="-1" role="main">
                        <div class="page-inner">
                            
<div id="book-search-results">
    <div class="search-noresults">
    
                                <section class="normal markdown-section">
                                
                                <h2 id="nosql&#x6982;&#x8FF0;">NoSQL&#x6982;&#x8FF0;</h2>
<p>&#x5927;&#x6570;&#x636E;&#x65F6;&#x4EE3;</p>
<blockquote>
<p>&#x5355;&#x673A;&#x65F6;&#x4EE3;</p>
</blockquote>
<p>&#x5B58;&#x5728;&#x7684;&#x95EE;&#x9898;</p>
<ol>
<li>&#x6570;&#x636E;&#x91CF;&#x592A;&#x5927;&#xFF0C;&#x4E00;&#x4E2A;&#x673A;&#x5668;&#x653E;&#x4E0D;&#x4E0B;</li>
<li>&#x6570;&#x636E;&#x7684;&#x7D22;&#x5F15;&#xFF08;B+ Tree&#xFF09;&#xFF0C;&#x4E00;&#x4E2A;&#x673A;&#x5668;&#x5185;&#x5B58;&#x653E;&#x4E0D;&#x4E0B;</li>
<li>&#x8BBF;&#x95EE;&#x91CF;&#xFF08;&#x8BFB;&#x5199;&#x6DF7;&#x5408;&#xFF09;&#xFF0C;&#x4E00;&#x4E2A;&#x670D;&#x52A1;&#x5668;&#x627F;&#x53D7;&#x4E0D;&#x4E86;</li>
</ol>
<blockquote>
<p>Memcached&#xFF08;&#x7F13;&#x5B58;&#xFF09;+ MySQL+&#x5782;&#x76F4;&#x62C6;&#x5206;</p>
</blockquote>
<p>&#x7F51;&#x7AD9;80%&#x60C5;&#x51B5;&#x90FD;&#x662F;&#x5728;&#x8BFB;&#xFF0C;&#x6BCF;&#x6B21;&#x53BB;&#x67E5;&#x8BE2;&#x5341;&#x5206;&#x9EBB;&#x70E6;&#xFF01;&#x51CF;&#x8F7B;&#x538B;&#x529B;&#xFF0C;&#x4F7F;&#x7528;&#x7F13;&#x5B58;&#x3002;</p>
<blockquote>
<p>&#x5206;&#x5E93;&#x5206;&#x8868; + &#x6C34;&#x5E73;&#x62C6;&#x5206; + MySQL&#x96C6;&#x7FA4;</p>
</blockquote>
<p>&#x65E9;&#x4E9B;&#x5E74;MyISAM&#xFF1A;&#x8868;&#x9501;</p>
<p>InnoDB&#xFF1A;&#x884C;&#x9501;</p>
<blockquote>
<p>&#x5982;&#x4ECA;&#x6700;&#x8FD1;&#x7684;&#x5E74;&#x4EE3;</p>
</blockquote>
<p>&#x70ED;&#x699C;&#x5B9E;&#x65F6;&#x66F4;&#x65B0;&#xFF0C;&#x6570;&#x636E;&#x91CF;&#x5927;&#xFF0C;&#x53D8;&#x5316;&#x5FEB;</p>
<p>MySQL&#x5173;&#x7CFB;&#x578B;&#x6570;&#x636E;&#x5E93;&#x4E0D;&#x591F;&#x7528;</p>
<h2 id="&#x4EC0;&#x4E48;&#x662F;nosql">&#x4EC0;&#x4E48;&#x662F;NoSQL</h2>
<blockquote>
<p>Not Only SQL</p>
</blockquote>
<p>&#x6CDB;&#x6307;&#x975E;&#x5173;&#x7CFB;&#x578B;&#x6570;&#x636E;&#x5E93;</p>
<p>&#x4F7F;&#x7528;&#x952E;&#x503C;&#x5BF9;&#x6765;&#x63A7;&#x5236;</p>
<blockquote>
<p>NoSQL&#x7279;&#x70B9;</p>
</blockquote>
<ol>
<li>&#x65B9;&#x4FBF;&#x6269;&#x5C55;&#xFF08;&#x6570;&#x636E;&#x4E4B;&#x95F4;&#x6CA1;&#x6709;&#x5173;&#x7CFB;&#xFF0C;&#x5F88;&#x597D;&#x6269;&#x5C55;&#xFF09;</li>
<li>&#x5927;&#x6570;&#x636E;&#x91CF;&#x9AD8;&#x6027;&#x80FD;&#xFF08;Redis 1&#x79D2;&#x5199;8&#x4E07;&#x6B21;&#xFF0C;&#x8BFB;11&#x4E07;&#xFF0C;&#x7F13;&#x5B58;&#x8BB0;&#x5F55;&#x6027;&#x80FD;&#x9AD8;&#xFF09;</li>
<li>&#x6570;&#x636E;&#x7C7B;&#x578B;&#x591A;&#x6837;&#xFF08;&#x4E0D;&#x9700;&#x8981;&#x8BBE;&#x8BA1;&#x6570;&#x636E;&#x5E93;&#xFF0C;&#x968F;&#x53D6;&#x968F;&#x7528;&#xFF09;</li>
<li>&#x4F20;&#x7EDF;RDBMS&#x548C;NoSQL</li>
</ol>
<pre><code>&#x4F20;&#x7EDF;&#x7684; RDBMS
- &#x7ED3;&#x6784;&#x5316;&#x7EC4;&#x7EC7;
- SQL
- &#x6570;&#x636E;&#x548C;&#x5173;&#x7CFB;&#x90FD;&#x5B58;&#x5728;&#x5355;&#x72EC;&#x7684;&#x8868;&#x4E2D;
- &#x64CD;&#x4F5C;&#x64CD;&#x4F5C;&#xFF0C;&#x6570;&#x636E;&#x5B9A;&#x4E49;&#x8BED;&#x8A00;
- &#x4E25;&#x683C;&#x7684;&#x4E00;&#x81F4;&#x6027;
- &#x57FA;&#x7840;&#x7684;&#x4E8B;&#x52A1;
&#x2026;&#x2026;
</code></pre><pre><code>NoSQL
- &#x4E0D;&#x4EC5;&#x4EC5;&#x662F;&#x6570;&#x636E;
- &#x6CA1;&#x6709;&#x56FA;&#x5B9A;&#x7684;&#x67E5;&#x8BE2;&#x8BED;&#x8A00;
- &#x952E;&#x503C;&#x5BF9;&#x5B58;&#x50A8;&#xFF0C;&#x5217;&#x5B58;&#x50A8;&#xFF0C;&#x6587;&#x6863;&#x5B58;&#x50A8;&#xFF0C;&#x56FE;&#x5F62;&#x6570;&#x636E;&#x5E93;
- &#x6700;&#x7EC8;&#x4E00;&#x81F4;&#x6027;
- CAP&#x5B9A;&#x7406;&#x548C;BASE
- &#x9AD8;&#x6027;&#x80FD;&#xFF0C;&#x9AD8;&#x53EF;&#x7528;&#xFF0C;&#x9AD8;&#x53EF;&#x6269;
&#x2026;
</code></pre><blockquote>
<p>&#x5927;&#x6570;&#x636E;&#x7684;3V&#x548C;3&#x9AD8; </p>
</blockquote>
<h2 id="nosql&#x7684;&#x56DB;&#x5927;&#x5206;&#x7C7B;">NoSQL&#x7684;&#x56DB;&#x5927;&#x5206;&#x7C7B;</h2>
<p>KV&#x952E;&#x503C;&#x5BF9;&#xFF1A;</p>
<ul>
<li>Redis</li>
</ul>
<p>&#x6587;&#x6863;&#x578B;&#x6570;&#x636E;&#x5E93;&#xFF08;bson&#x683C;&#x5F0F;&#x548C;json&#xFF09;&#xFF1A;</p>
<ul>
<li>MongoDB<ul>
<li>&#x5206;&#x5E03;&#x5F0F;&#x6587;&#x4EF6;&#x5B58;&#x50A8;&#x7684;&#x6570;&#x636E;&#x5E93;&#xFF0C;c++&#x7F16;&#x5199;&#xFF0C;&#x5904;&#x7406;&#x5927;&#x91CF;&#x6587;&#x6863;</li>
<li>&#x4ECB;&#x4E8E;&#x5173;&#x7CFB;&#x578B;&#x4E0E;&#x975E;&#x5173;&#x7CFB;&#x578B;&#x6570;&#x636E;&#x5E93;&#x4E4B;&#x95F4;</li>
</ul>
</li>
</ul>
<p>&#x5217;&#x5B58;&#x50A8;&#x6570;&#x636E;&#x5E93;&#xFF1A;</p>
<p>&#x56FE;&#x5173;&#x7CFB;&#x6570;&#x636E;&#x5E93;&#xFF1A;&#x5B58;&#x5173;&#x7CFB;</p>
<h2 id="redis&#x5165;&#x95E8;">Redis&#x5165;&#x95E8;</h2>
<blockquote>
<p>Remote Dictionary Server</p>
</blockquote>
<p>&#x80FD;&#x5E72;&#x5565;&#xFF1F;</p>
<ol>
<li>&#x5185;&#x5B58;&#x5B58;&#x50A8;&#xFF0C;&#x6301;&#x4E45;&#x5316;&#xFF08;rdb&#x3001;aof&#xFF09;</li>
<li>&#x6548;&#x7387;&#x9AD8;&#xFF0C;&#x53EF;&#x4EE5;&#x7528;&#x4E8E;&#x9AD8;&#x901F;&#x7F13;&#x5B58;</li>
<li>&#x53D1;&#x5E03;&#x8BA2;&#x9605;&#x7CFB;&#x7EDF;</li>
<li>&#x5730;&#x56FE;&#x4FE1;&#x606F;&#x5206;&#x6790;</li>
<li>&#x8BA1;&#x65F6;&#x5668;&#x3001;&#x8BA1;&#x6570;&#x5668;&#xFF08;&#x6D4F;&#x89C8;&#x91CF;&#xFF09;</li>
<li>&#x2026;&#x2026;</li>
</ol>
<p>&#x7279;&#x6027;&#xFF1A;</p>
<ol>
<li>&#x591A;&#x6837;&#x6570;&#x636E;&#x7C7B;&#x578B;</li>
<li>&#x6301;&#x4E45;&#x5316;</li>
<li>&#x96C6;&#x7FA4;</li>
<li>&#x4E8B;&#x52A1;</li>
</ol>
<h3 id="windows&#x5B89;&#x88C5;">Windows&#x5B89;&#x88C5;</h3>
<p><a href="https://github.com/rgl/redis/downloads" target="_blank">https://github.com/rgl/redis/downloads</a></p>
<h3 id="linux&#x5B89;&#x88C5;">Linux&#x5B89;&#x88C5;</h3>
<p>6.x&#x4EE5;&#x4E0A;&#x7248;&#x672C;&#x9700;&#x8981;&#x66F4;&#x65B0;gcc</p>
<pre><code>tar -xzvf
make 
make install
</code></pre><p>&#x4FEE;&#x6539;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x540E;&#x53F0;&#x542F;&#x52A8;</p>
<pre><code>daemonize yes
</code></pre><h3 id="&#x6D4B;&#x8BD5;&#x6027;&#x80FD;">&#x6D4B;&#x8BD5;&#x6027;&#x80FD;</h3>
<pre><code class="lang-shell">redis-benchmark -h localhost -p 6379 -c 100 -n 100000
</code></pre>
<h3 id="&#x57FA;&#x672C;&#x547D;&#x4EE4;">&#x57FA;&#x672C;&#x547D;&#x4EE4;</h3>
<p>&#x6E05;&#x7A7A;&#x5F53;&#x524D;&#x6570;&#x636E;&#x5E93;<code>flushdb</code></p>
<p>&#x6E05;&#x7A7A;&#x5168;&#x90E8;&#x6570;&#x636E;&#x5E93;<code>flushall</code></p>
<p>&#x57FA;&#x7840;&#x77E5;&#x8BC6;</p>
<blockquote>
<p>Redis&#x662F;&#x5355;&#x7EBF;&#x7A0B;&#x7684;</p>
</blockquote>
<p>6.0.0&#x4EE5;&#x540E;&#x662F;&#x591A;&#x7EBF;&#x7A0B;</p>
<p>16&#x4E2A;&#x6570;&#x636E;&#x5E93;&#xFF0C;&#x9ED8;&#x8BA4;&#x4F7F;&#x7528;&#x7B2C;0&#x4E2A;</p>
<p>&#x547D;&#x4EE4;</p>
<pre><code>set    #set key
get    #get key
keys * #&#x67E5;&#x770B;&#x6240;&#x6709;key
exists #&#x5224;&#x65AD;&#x5F53;&#x524D;key&#x662F;&#x5426;&#x5B58;&#x5728;
move   #&#x79FB;&#x9664;&#x5F53;&#x524D;key
expire #&#x8BBE;&#x7F6E;key&#x65F6;&#x95F4;&#x8FC7;&#x671F;
ttl    #&#x67E5;&#x770B;&#x5F53;&#x524D;key&#x7684;&#x5269;&#x4F59;&#x65F6;&#x95F4;
type   #&#x67E5;&#x770B;key&#x7C7B;&#x578B;
</code></pre><h2 id="&#x4E94;&#x5927;&#x6570;&#x636E;&#x7C7B;&#x578B;">&#x4E94;&#x5927;&#x6570;&#x636E;&#x7C7B;&#x578B;</h2>
<h3 id="redis-key">Redis-Key</h3>
<h3 id="string">String</h3>
<pre><code class="lang-shell">append [key] [string]    #&#x8FFD;&#x52A0;&#x5B57;&#x7B26;&#x4E32;
strlen [key]               #&#x83B7;&#x53D6;&#x5B57;&#x7B26;&#x4E32;&#x957F;&#x5EA6;
incr                    #&#x52A0;&#x4E00;
decr                    #&#x51CF;&#x4E00;
incrby [key] 10         #&#x4E00;&#x6B21;&#x52A0;10&#xFF08;&#x6B65;&#x957F;&#xFF09;
decrby                    
getrange [key] 0 3        #&#x622A;&#x53D6;&#x5B57;&#x7B26;&#x4E32;[0,3]&#xFF08;0 -1&#x6240;&#x6709;&#x540C;get key&#xFF09;
setrange [key] 

setex                    #set with expire
setnx                    #set if not exist

mset
mget

127.0.0.1:6379&gt; mset k1 v1 k2 v2 k3 v3
OK
127.0.0.1:6379&gt; mget k1 k2 k3
1) &quot;v1&quot;
2) &quot;v2&quot;
3) &quot;v3&quot;
127.0.0.1:6379&gt; msetnx k1 v1 k4 v4   #&#x539F;&#x5B50;&#x6027;&#x64CD;&#x4F5C;
(integer) 0
127.0.0.1:6379&gt; get k4
(nil)

#&#x5BF9;&#x8C61;
set user:{id}:{filed}


127.0.0.1:6379&gt; getset db redis       #&#x5982;&#x679C;&#x4E0D;&#x5B58;&#x5728;&#xFF0C;&#x76F8;&#x5F53;&#x4E8E;set
(nil)
127.0.0.1:6379&gt; get db
&quot;redis&quot;
127.0.0.1:6379&gt; getset db mongodb    #&#x5982;&#x679C;&#x5B58;&#x5728;&#xFF0C;&#x5148;get&#x518D;set
&quot;redis&quot;
127.0.0.1:6379&gt; get db
&quot;mongodb&quot;
</code></pre>
<h3 id="list">List</h3>
<pre><code class="lang-shell">127.0.0.1:6379&gt; LPUSH list one
(integer) 1
127.0.0.1:6379&gt; LPUSH list two
(integer) 2
127.0.0.1:6379&gt; LPUSH list three
(integer) 3
127.0.0.1:6379&gt; LRANGE list 0 -1
1) &quot;three&quot;
2) &quot;two&quot;
3) &quot;one&quot;
127.0.0.1:6379&gt; LRANGE list 0 1
1) &quot;three&quot;
2) &quot;two&quot;
127.0.0.1:6379&gt; rpush list right
(integer) 4
127.0.0.1:6379&gt; LRANGE list 0 -1
1) &quot;three&quot;
2) &quot;two&quot;
3) &quot;one&quot;
4) &quot;right&quot;

127.0.0.1:6379&gt; LPOP list            #&#x79FB;&#x9664;list&#x7B2C;&#x4E00;&#x4E2A;
&quot;three&quot;    
127.0.0.1:6379&gt; RPOP list            #&#x79FB;&#x9664;list&#x6700;&#x540E;&#x4E00;&#x4E2A;
&quot;right&quot;
127.0.0.1:6379&gt; LRANGE list 0 -1
1) &quot;two&quot;
2) &quot;one&quot;
127.0.0.1:6379&gt; lindex list 0        #&#x901A;&#x8FC7;&#x4E0B;&#x6807;&#x83B7;&#x53D6;&#x503C;
&quot;two&quot;
127.0.0.1:6379&gt; lindex list 1
&quot;one&quot;
127.0.0.1:6379&gt; LLEN list            #&#x83B7;&#x53D6;&#x957F;&#x5EA6;
(integer) 2

lrem #&#x79FB;&#x9664;list&#x4E2D;&#x6307;&#x5B9A;&#x4E2A;&#x6570;&#x7684;&#x503C;

ltrim #&#x901A;&#x8FC7;&#x4E0B;&#x6807;&#x622A;&#x53D6;&#x6307;&#x5B9A;&#x957F;&#x5EA6;&#xFF0C;list&#x53EA;&#x5269;&#x4E0B;&#x622A;&#x53D6;&#x7684;&#x5143;&#x7D20;

rpoplpush #&#x79FB;&#x9664;&#x5217;&#x8868;&#x7684;&#x6700;&#x540E;&#x4E00;&#x4E2A;&#x5143;&#x7D20;&#x5230;&#x65B0;&#x5217;&#x8868;

lset #&#x5C06;&#x5217;&#x8868;&#x6307;&#x5B9A;&#x4E0B;&#x6807;&#x7684;&#x503C;&#x66FF;&#x6362;&#x4E3A;&#x53E6;&#x4E00;&#x4E2A;&#x503C;&#xFF0C;&#x5373;&#x66F4;&#x65B0;&#x64CD;&#x4F5C;

linsert #&#x53EF;&#x6307;&#x5B9A;&#x524D;&#x9762;&#x540E;&#x9762;&#x4F4D;&#x7F6E;&#x63D2;&#x5165;
</code></pre>
<h3 id="set">Set</h3>
<blockquote>
<p>&#x4E0D;&#x91CD;&#x590D;</p>
</blockquote>
<pre><code>sadd myset 
smembers myset
sismember
srem    #&#x79FB;&#x9664;&#x6307;&#x5B9A;&#x5143;&#x7D20;
scard      #set&#x4E2D;&#x5143;&#x7D20;&#x4E2A;&#x6570;
srandmember myset     #&#x968F;&#x673A;&#x62BD;&#x51FA;&#x6307;&#x5B9A;&#x5143;&#x7D20;

spop    #&#x968F;&#x673A;&#x5220;&#x9664;
sdiff      #&#x5DEE;&#x96C6;
sinter    #&#x4EA4;&#x96C6;
sunion    #&#x5E76;&#x96C6;
</code></pre><h3 id="hash">Hash</h3>
<blockquote>
<p>Map&#x96C6;&#x5408;&#xFF0C;key-map &#x672C;&#x8D28;&#x548C;String&#x6CA1;&#x6709;&#x4EC0;&#x4E48;&#x533A;&#x522B;&#xFF0C;&#x8FD8;&#x662F;&#x4E00;&#x4E2A;&#x7B80;&#x5355;&#x7684;key-value</p>
</blockquote>
<pre><code>hset myhash field value
hget
hmset
hmget
hgetall
hdel 
hlen    
hexists myhash field
hincrby
hsetnx
</code></pre><p>&#x5BF9;&#x8C61;&#x7528;hash&#x5B58;&#x50A8;&#x65B9;&#x4FBF;</p>
<h3 id="zset&#xFF08;&#x6709;&#x5E8F;&#x96C6;&#x5408;&#xFF09;">Zset&#xFF08;&#x6709;&#x5E8F;&#x96C6;&#x5408;&#xFF09;</h3>
<pre><code class="lang-bash">zadd
zrange
zrangebyscore key min max
zcard    <span class="hljs-comment">#&#x83B7;&#x53D6;&#x6709;&#x5E8F;&#x96C6;&#x5408;&#x4E2D;&#x7684;&#x4E2A;&#x6570;</span>
zcount    <span class="hljs-comment">#&#x83B7;&#x53D6;&#x6307;&#x5B9A;&#x533A;&#x95F4;&#x7684;&#x6210;&#x5458;&#x6570;&#x91CF;</span>
</code></pre>
<h2 id="&#x4E09;&#x79CD;&#x7279;&#x6B8A;&#x7C7B;&#x578B;">&#x4E09;&#x79CD;&#x7279;&#x6B8A;&#x7C7B;&#x578B;</h2>
<h3 id="geospatial&#x5730;&#x7406;&#x4F4D;&#x7F6E;">geospatial&#x5730;&#x7406;&#x4F4D;&#x7F6E;</h3>
<p>Redis&#x7684;Geo</p>
<pre><code>GEOADD
GEODIST
GEOHASH
GEOPOSH
GEOADIUS
</code></pre><h3 id="hyperloglog">Hyperloglog</h3>
<blockquote>
<p>&#x4EC0;&#x4E48;&#x662F;&#x57FA;&#x6570;&#xFF1F;&#xFF08;&#x4E0D;&#x91CD;&#x590D;&#x7684;&#x5143;&#x7D20;&#xFF09;</p>
</blockquote>
<p>&#x7528;&#x6765;&#x505A;&#x57FA;&#x6570;&#x7EDF;&#x8BA1;&#x7684;&#x7B97;&#x6CD5;</p>
<pre><code>PFADD mykey a b c d e f g h i j
PFCOUNT mykey
PFADD mykey2 i j k l m n o
PFMERGE mykey3 mykey2 mykey
</code></pre><h3 id="bitmaps">Bitmaps</h3>
<blockquote>
<p>&#x4F4D;&#x5B58;&#x50A8;</p>
</blockquote>
<p>&#x4E24;&#x4E2A;&#x72B6;&#x6001;0 1</p>
<pre><code>setbit
getbit
bitcount
</code></pre><h2 id="&#x4E8B;&#x52A1;">&#x4E8B;&#x52A1;</h2>
<p>Redis&#x4E8B;&#x52A1;&#x672C;&#x8D28;&#xFF1A;&#x4E00;&#x7EC4;&#x547D;&#x4EE4;&#x7684;&#x96C6;&#x5408;&#xFF01;&#x4E00;&#x4E2A;&#x4E8B;&#x7269;&#x4E2D;&#x6240;&#x6709;&#x547D;&#x4EE4;&#x90FD;&#x4F1A;&#x5E8F;&#x5217;&#x5316;&#xFF0C;&#x5728;&#x4E8B;&#x52A1;&#x6267;&#x884C;&#x8FC7;&#x7A0B;&#x4E2D;&#xFF0C;&#x4F1A;&#x6309;&#x7167;&#x987A;&#x5E8F;&#x6267;&#x884C;&#xFF01;</p>
<p>&#x4E00;&#x6B21;&#x6027;&#x3001;&#x987A;&#x5E8F;&#x6027;&#x3001;&#x6392;&#x4ED6;&#x6027;&#xFF01;&#x6267;&#x884C;&#x4E00;&#x4E9B;&#x5217;&#x7684;&#x547D;&#x4EE4;</p>
<p>==Redis&#x5355;&#x6761;&#x547D;&#x4EE4;&#x4FDD;&#x8BC1;&#x539F;&#x5B50;&#x6027;&#xFF0C;&#x4F46;&#x662F;&#x4E8B;&#x52A1;&#x4E0D;&#x4FDD;&#x8BC1;&#x539F;&#x5B50;&#x6027;==</p>
<p>Redis&#x4E8B;&#x52A1;&#x6CA1;&#x6709;&#x9694;&#x79BB;&#x7EA7;&#x522B;&#x7684;&#x6982;&#x5FF5;</p>
<p>Redis&#x7684;&#x4E8B;&#x52A1;&#xFF1A;</p>
<ul>
<li>&#x5F00;&#x542F;&#x4E8B;&#x52A1;&#xFF08;multi&#xFF09;</li>
<li>&#x547D;&#x4EE4;&#x5165;&#x961F;&#xFF08;&#x2026;&#x2026;&#xFF09;</li>
<li>&#x6267;&#x884C;&#x4E8B;&#x52A1;&#xFF08;exec&#xFF09;</li>
</ul>
<blockquote>
<p>&#x6B63;&#x5E38;&#x6267;&#x884C;&#x4E8B;&#x52A1;</p>
<p>&#x653E;&#x5F03;&#x4E8B;&#x52A1;</p>
</blockquote>
<p>discard</p>
<blockquote>
<p>&#x7F16;&#x8BD1;&#x5F02;&#x5E38;  &#x5168;&#x90E8;&#x547D;&#x4EE4;&#x4E0D;&#x6267;&#x884C;</p>
<p>&#x8FD0;&#x884C;&#x5F02;&#x5E38; &#x5176;&#x4ED6;&#x547D;&#x4EE4;&#x6B63;&#x5E38;&#x6267;&#x884C;</p>
<p>&#x76D1;&#x63A7;</p>
</blockquote>
<h3 id="&#x60B2;&#x89C2;&#x9501;&#xFF1A;"><strong>&#x60B2;&#x89C2;&#x9501;</strong>&#xFF1A;</h3>
<ul>
<li>&#x8BA4;&#x4E3A;&#x4EC0;&#x4E48;&#x65F6;&#x5019;&#x90FD;&#x4F1A;&#x51FA;&#x95EE;&#x9898;&#xFF0C;&#x65E0;&#x8BBA;&#x505A;&#x4EC0;&#x4E48;&#x90FD;&#x52A0;&#x9501;</li>
</ul>
<h3 id="&#x4E50;&#x89C2;&#x9501;&#xFF1A;"><strong>&#x4E50;&#x89C2;&#x9501;</strong>&#xFF1A;</h3>
<ul>
<li>&#x8BA4;&#x4E3A;&#x4EC0;&#x4E48;&#x65F6;&#x5019;&#x90FD;&#x4E0D;&#x4F1A;&#x51FA;&#x73B0;&#x95EE;&#x9898;&#xFF0C;&#x6240;&#x6709;&#x4E0D;&#x4F1A;&#x4E0A;&#x9501;&#xFF01;&#x66F4;&#x65B0;&#x6570;&#x636E;&#x7684;&#x65F6;&#x5019;&#x53BB;&#x5224;&#x65AD;&#x4E00;&#x4E0B;&#xFF0C;&#x5728;&#x6B64;&#x671F;&#x95F4;&#x662F;&#x5426;&#x6709;&#x4EBA;&#x4FEE;&#x6539;&#x8FC7;&#x8FD9;&#x4E2A;&#x6570;&#x636E;</li>
<li>&#x83B7;&#x53D6;version</li>
<li>&#x66F4;&#x65B0;&#x7684;&#x65F6;&#x5019;&#x6BD4;&#x8F83;version</li>
</ul>
<blockquote>
<p>Redis&#x6D4B;&#x76D1;&#x89C6;&#x6D4B;&#x8BD5;</p>
</blockquote>
<h2 id="jedis">Jedis</h2>
<h2 id="redis&#x914D;&#x7F6E;&#x6587;&#x4EF6;">Redis&#x914D;&#x7F6E;&#x6587;&#x4EF6;</h2>
<ol>
<li>&#x914D;&#x7F6E;&#x6587;&#x4EF6; unit&#x5355;&#x4F4D; &#x5BF9;&#x5927;&#x5C0F;&#x5199;&#x4E0D;&#x654F;&#x611F;</li>
</ol>
<h2 id="redis&#x6301;&#x4E45;&#x5316;">Redis&#x6301;&#x4E45;&#x5316;</h2>
<h3 id="rdb&#xFF08;snapshotting&#xFF09;&#xFF08;redis&#x9ED8;&#x8BA4;&#x6301;&#x4E45;&#x5316;&#xFF09;">RDB&#xFF08;snapshotting&#xFF09;&#xFF08;Redis&#x9ED8;&#x8BA4;&#x6301;&#x4E45;&#x5316;&#xFF09;</h3>
<p>==&#x4FDD;&#x5B58;&#x7684;&#x6587;&#x4EF6;&#x662F;dump.rdb== &#x90FD;&#x662F;&#x5728;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x5FEB;&#x7167;&#x4E2D;&#x8FDB;&#x884C;&#x914D;&#x7F6E;</p>
<blockquote>
<p>&#x89E6;&#x53D1;&#x673A;&#x5236;</p>
</blockquote>
<ol>
<li>save&#x7684;&#x89C4;&#x5219;&#x6EE1;&#x8DB3;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x4F1A;&#x81EA;&#x52A8;&#x89E6;&#x53D1;rdb&#x89C4;&#x5219;</li>
<li>&#x6267;&#x884C;flushall&#x547D;&#x4EE4;&#xFF0C;&#x4E5F;&#x4F1A;&#x89E6;&#x53D1;rdb&#x89C4;&#x5219;</li>
<li>&#x9000;&#x51FA;redis&#xFF0C;&#x4E5F;&#x4F1A;&#x4EA7;&#x751F;rdb&#x6587;&#x4EF6;</li>
</ol>
<p>&#x5907;&#x4EFD;&#x5C31;&#x81EA;&#x52A8;&#x751F;&#x6210;&#x4E00;&#x4E2A;dump.rdb</p>
<blockquote>
<p>&#x6062;&#x590D;rdb&#x6587;&#x4EF6;</p>
</blockquote>
<p>&#x5728;redis&#x542F;&#x52A8;&#x76EE;&#x5F55;&#x4E2D;&#x653E;rdb&#x6587;&#x4EF6;</p>
<pre><code class="lang-bash">save 900 1     <span class="hljs-comment">#&#x5728;900&#x79D2;&#xFF08;15&#x5206;&#x949F;&#xFF09;&#x4E4B;&#x540E;&#xFF0C;&#x5982;&#x679C;&#x81F3;&#x5C11;&#x6709;1&#x4E2A;key&#x53D1;&#x751F;&#x53D8;&#x5316;&#xFF0C;Redis&#x5C31;&#x4F1A;&#x81EA;&#x52A8;&#x89E6;&#x53D1;BGSAVE&#x547D;&#x4EE4;&#x521B;&#x5EFA;&#x5FEB;&#x7167;</span>
save 300 10 <span class="hljs-comment">#&#x5728;300&#x79D2;&#xFF08;5&#x5206;&#x949F;&#xFF09;&#x4E4B;&#x540E;&#xFF0C;&#x5982;&#x679C;&#x81F3;&#x5C11;&#x6709;10&#x4E2A;key&#x53D1;&#x751F;&#x53D8;&#x5316;&#xFF0C;Redis&#x5C31;&#x4F1A;&#x81EA;&#x52A8;&#x89E6;&#x53D1;BGSAVE&#x547D;&#x4EE4;&#x521B;&#x5EFA;&#x5FEB;&#x7167;</span>
save 60 10000<span class="hljs-comment">#&#x5728;60&#x79D2;&#xFF08;1&#x5206;&#x949F;&#xFF09;&#x4E4B;&#x540E;&#xFF0C;&#x5982;&#x679C;&#x81F3;&#x5C11;&#x6709;10000&#x4E2A;key&#x53D1;&#x751F;&#x53D8;&#x5316;&#xFF0C;Redis&#x5C31;&#x4F1A;&#x81EA;&#x52A8;&#x89E6;&#x53D1;BGSAVE&#x547D;&#x4EE4;&#x521B;&#x5EFA;&#x5FEB;&#x7167;</span>
</code></pre>
<h3 id="aof&#xFF08;append-only-file&#xFF09;">AOF&#xFF08;Append Only File&#xFF09;</h3>
<p>==&#x4FDD;&#x5B58;&#x7684;&#x6587;&#x4EF6;&#x662F;appendonly.aof==</p>
<p><strong>&#x5C06;&#x6211;&#x4EEC;&#x6240;&#x6709;&#x547D;&#x4EE4;&#x8BB0;&#x5F55;&#x4E0B;&#x6765;&#xFF0C;&#x6062;&#x590D;&#x7684;&#x65F6;&#x5019;&#x91CD;&#x65B0;&#x6267;&#x884C;</strong></p>
<p>&#x9ED8;&#x8BA4;&#x4E0D;&#x5F00;&#x542F;&#xFF0C;&#x5C06;appendonly no&#x6539;&#x4E3A;yes&#x5373;&#x53EF;&#x751F;&#x6548;</p>
<pre><code class="lang-bash">appendfsync always  <span class="hljs-comment">#&#x6BCF;&#x6B21;&#x6709;&#x6570;&#x636E;&#x4FEE;&#x6539;&#x53D1;&#x751F;&#x65F6;&#x90FD;&#x4F1A;&#x5199;&#x5165;AOF&#x6587;&#x4EF6;&#xFF0C;&#x8FD9;&#x6837;&#x4F1A;&#x4E25;&#x91CD;&#x964D;&#x4F4E;Redis&#x7684;&#x901F;&#x5EA6;</span>
appendfsync    everysec <span class="hljs-comment">#&#x6BCF;&#x79D2;&#x949F;&#x540C;&#x6B65;&#x4E00;&#x6B21;&#xFF0C;&#x663E;&#x793A;&#x5730;&#x5C06;&#x591A;&#x4E2A;&#x547D;&#x4EE4;&#x540C;&#x6B65;&#x5230;&#x786C;&#x76D8;</span>
appendfsync no        <span class="hljs-comment">#&#x8BA9;&#x64CD;&#x4F5C;&#x7CFB;&#x7EDF;&#x51B3;&#x5B9A;&#x4F55;&#x65F6;&#x8FDB;&#x884C;&#x540C;&#x6B65;</span>
</code></pre>
<p>&#x91CD;&#x542F;&#xFF0C;redis&#x5C31;&#x53EF;&#x4EE5;&#x751F;&#x6548;&#x4E86;</p>
<p>aof&#x6587;&#x4EF6;&#x6709;&#x95EE;&#x9898;&#xFF0C;&#x65E0;&#x6CD5;&#x542F;&#x52A8;redis</p>
<p>redis&#x63D0;&#x4F9B;&#x4E86;&#x4E00;&#x4E2A;&#x5DE5;&#x5177;redis-check-aof</p>
<h2 id="redis&#x53D1;&#x5E03;&#x8BA2;&#x9605;">Redis&#x53D1;&#x5E03;&#x8BA2;&#x9605;</h2>
<pre><code class="lang-bash">redis 127.0.0.1:6379&gt; SUBSCRIBE ylldgzh
Reading messages... (press Ctrl-C to quit)
1) <span class="hljs-string">&quot;subscribe&quot;</span>
2) <span class="hljs-string">&quot;ylldgzh&quot;</span>
3) (<span class="hljs-built_in">integer</span>) 1
1) <span class="hljs-string">&quot;message&quot;</span>
2) <span class="hljs-string">&quot;ylldgzh&quot;</span>
3) <span class="hljs-string">&quot;hello,yll&quot;</span>
1) <span class="hljs-string">&quot;message&quot;</span>
2) <span class="hljs-string">&quot;ylldgzh&quot;</span>
3) <span class="hljs-string">&quot;hello,redis&quot;</span>
<span class="hljs-comment">#&#x7B49;&#x5F85;&#x8BFB;&#x53D6;&#x4FE1;&#x606F;</span>
<span class="hljs-comment">#&#x53D1;&#x9001;&#x7AEF;</span>
redis 127.0.0.1:6379&gt; PUBLISH ylldgzh <span class="hljs-string">&quot;hello,yll&quot;</span>
(<span class="hljs-built_in">integer</span>) 1
redis 127.0.0.1:6379&gt; PUBLISH ylldgzh <span class="hljs-string">&quot;hello,redis&quot;</span>
(<span class="hljs-built_in">integer</span>) 1
redis 127.0.0.1:6379&gt;
</code></pre>
<h2 id="redis&#x4E3B;&#x4ECE;&#x590D;&#x5236;">Redis&#x4E3B;&#x4ECE;&#x590D;&#x5236;</h2>
<p>&#x662F;&#x6307;&#x5C06;&#x4E00;&#x53F0;Redis&#x670D;&#x52A1;&#x5668;&#x7684;&#x5185;&#x5BB9;&#xFF0C;&#x590D;&#x5236;&#x5230;&#x5176;&#x4ED6;Redis&#x670D;&#x52A1;&#x5668;&#xFF0C;&#x524D;&#x8005;&#x79F0;&#x4E3A;&#x4E3B;&#x8282;&#x70B9;&#xFF0C;&#x540E;&#x8005;&#x79F0;&#x4E3A;&#x4ECE;&#x8282;&#x70B9;</p>
<p>&#x6570;&#x636E;&#x7684;&#x590D;&#x5236;&#x662F;&#x5355;&#x5411;&#x7684;&#x3002;</p>
<p>&#x4E3B;&#x4ECE;&#x590D;&#x5236;&#xFF0C;&#x8BFB;&#x5199;&#x5206;&#x79BB;&#xFF01;</p>
<p><code>info replication</code></p>
<p>&#x914D;&#x7F6E;&#x4E09;&#x53F0;Redis&#x670D;&#x52A1;&#x5668;</p>
<h3 id="&#x4E00;&#x4E3B;&#x4E8C;&#x4ECE;">&#x4E00;&#x4E3B;&#x4E8C;&#x4ECE;</h3>
<p>&#x9ED8;&#x8BA4;&#x90FD;&#x662F;&#x4E3B;&#x8282;&#x70B9;&#xFF0C;&#x4E00;&#x822C;&#x53EA;&#x9700;&#x8981;&#x914D;&#x7F6E;&#x4ECE;&#x673A;</p>
<pre><code class="lang-bash">127.0.0.1:6380&gt; SLAVEOF 127.0.0.1 6379    <span class="hljs-comment">#&#x8BA4;&#x4E3B;&#x673A;</span>
OK
127.0.0.1:6380&gt; info replication
<span class="hljs-comment"># Replication</span>
role:slave
master_host:127.0.0.1
master_port:6379
master_link_status:down
master_last_io_seconds_ago:-1
master_sync_<span class="hljs-keyword">in</span>_progress:0
slave_repl_offset:1
master_link_down_since_seconds:1592916819
slave_priority:100
slave_<span class="hljs-built_in">read</span>_only:1
connected_slaves:0
master_replid:94c953e3da093a084e25e06eb232fb7eb12e5d14
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
127.0.0.1:6380&gt;
</code></pre>
<p>&#x771F;&#x5B9E;&#x7684;&#x914D;&#x7F6E;&#x662F; &#x5728;&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#x4E2D;&#x914D;&#x7F6E;&#xFF0C;&#x8FD9;&#x6837;&#x662F;&#x6C38;&#x4E45;&#x7684; &#x7528;&#x547D;&#x4EE4;&#xFF0C;&#x662F;&#x6682;&#x65F6;&#x7684;</p>
<p>&#x4E3B;&#x673A;&#x53EF;&#x4EE5;&#x5199;&#xFF0C;&#x4ECE;&#x673A;&#x4E0D;&#x80FD;&#x5199;&#x53EA;&#x80FD;&#x8BFB;&#xFF01;&#x4E3B;&#x673A;&#x4E2D;&#x6240;&#x6709;&#x4FE1;&#x606F;&#x548C;&#x6570;&#x636E;&#xFF0C;&#x90FD;&#x4F1A;&#x590D;&#x5236;&#x5230;&#x4ECE;&#x673A;</p>
<p>&#x6D4B;&#x8BD5;:&#x4E3B;&#x673A;&#x65AD;&#x5F00;&#x8FDE;&#x63A5;&#xFF0C;&#x4ECE;&#x673A;&#x4F9D;&#x65E7;&#x8FDE;&#x63A5;&#x5230;&#x4E3B;&#x673A;&#xFF0C;&#x4F46;&#x662F;&#x6CA1;&#x6709;&#x5199;&#x64CD;&#x4F5C;&#xFF0C;&#x8FD9;&#x4E2A;&#x65F6;&#x5019;&#xFF0C;&#x4E3B;&#x673A;&#x5982;&#x679C;&#x56DE;&#x6765;&#x4E86;&#xFF0C;&#x4ECE;&#x673A;&#x4F9D;&#x65E7;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x83B7;&#x53D6;&#x5230;&#x4E3B;&#x673A;&#x5199;&#x7684;&#x4FE1;&#x606F;&#xFF01;</p>
<p>&#x4E3B;&#x673A;&#x65AD;&#x5F00;&#xFF0C;&#x4ECE;&#x673A;&#x53EF;&#x4F7F;&#x7528;&#x547D;&#x4EE4;    <code>slaveof no one</code>&#x8BA9;&#x81EA;&#x5DF1;&#x53D8;&#x6210;&#x4E3B;&#x673A;&#x4E0B;</p>
<h2 id="&#x54E8;&#x5175;&#x6A21;&#x5F0F;">&#x54E8;&#x5175;&#x6A21;&#x5F0F;</h2>
<p>&#xFF08;&#x81EA;&#x52A8;&#x9009;&#x8001;&#x5927;&#xFF09;</p>
<blockquote>
<p>&#x6D4B;&#x8BD5;</p>
</blockquote>
<ol>
<li>&#x914D;&#x7F6E;&#x54E8;&#x5175;&#x914D;&#x7F6E;&#x6587;&#x4EF6;sentinel.conf</li>
</ol>
<pre><code>sentinel monitor myredis 127.0.0.1 6379 1
</code></pre><p>&#x540E;&#x9762;&#x7684;&#x6570;&#x5B57;1&#xFF0C;&#x4EE3;&#x8868;&#x4E3B;&#x673A;&#x6302;&#x4E86;&#xFF0C;slave&#x6295;&#x7968;&#x770B;&#x8BA9;&#x8C01;&#x63A5;&#x66FF;&#x6210;&#x4E3A;&#x4E3B;&#x673A;&#xFF0C;&#x7968;&#x6570;&#x6700;&#x591A;&#x7684;&#x6210;&#x4E3A;&#x4E3B;&#x673A;</p>
<pre><code>redis-sentinel sentinel.conf  #&#x5F00;&#x542F;&#x54E8;&#x5175;
</code></pre><p>&#x4E3B;&#x673A;&#x5B95;&#x6389;&#x540E;&#x518D;&#x56DE;&#x6765;&#x53EA;&#x4F1A;&#x6210;&#x4E3A;&#x65B0;&#x4E3B;&#x673A;&#x7684;&#x4ECE;&#x673A; </p>
<h2 id="redis&#x7F13;&#x5B58;&#x7A7F;&#x900F;&#x548C;&#x96EA;&#x5D29;">Redis&#x7F13;&#x5B58;&#x7A7F;&#x900F;&#x548C;&#x96EA;&#x5D29;</h2>
<blockquote>
<p>&#x670D;&#x52A1;&#x7684;&#x9AD8;&#x53EF;&#x7528;&#x95EE;&#x9898;</p>
</blockquote>
<h3 id="&#x7F13;&#x5B58;&#x7A7F;&#x900F;">&#x7F13;&#x5B58;&#x7A7F;&#x900F;</h3>
<blockquote>
<p>&#x5DEE;&#x4E0D;&#x591A;</p>
</blockquote>
<p>&#x7528;&#x6237;&#x60F3;&#x8981;&#x67E5;&#x8BE2;&#x6570;&#x636E;&#xFF0C;&#x53D1;&#x73B0;redis&#x5185;&#x5B58;&#x6570;&#x636E;&#x5E93;&#x6CA1;&#x6709;&#xFF0C;&#x4E5F;&#x5C31;&#x662F;&#x7F13;&#x5B58;&#x6CA1;&#x6709;&#x547D;&#x4E2D;&#xFF0C;&#x4E8E;&#x662F;&#x5411;&#x6301;&#x4E45;&#x5C42;&#x6570;&#x636E;&#x5E93;&#x67E5;&#x8BE2;&#x3002;&#x53D1;&#x73B0;&#x4E5F;&#x6CA1;&#x6709;&#xFF0C;&#x4E8E;&#x662F;&#x672C;&#x6B21;&#x67E5;&#x8BE2;&#x5931;&#x8D25;&#x3002;&#x5F53;&#x7528;&#x6237;&#x5F88;&#x591A;&#x65F6;&#x3002;&#x7F13;&#x5B58;&#x90FD;&#x6CA1;&#x6709;&#x547D;&#x4E2D;&#xFF0C;&#x4E8E;&#x662F;&#x90FD;&#x53BB;&#x8BF7;&#x6C42;&#x6301;&#x4E45;&#x5C42;&#x6570;&#x636E;&#x5E93;&#x3002;&#x8FD9;&#x7ED9;&#x6301;&#x4E45;&#x5C42;&#x6570;&#x636E;&#x5E93;&#x9020;&#x6210;&#x5F88;&#x5927;&#x7684;&#x538B;&#x529B;&#xFF0C;&#x8FD9;&#x65F6;&#x5019;&#x76F8;&#x5F53;&#x4E8E;&#x51FA;&#x73B0;&#x4E86;&#x7F13;&#x5B58;&#x7A7F;&#x900F;</p>
<blockquote>
<p>&#x89E3;&#x51B3;&#x65B9;&#x6848;</p>
</blockquote>
<h4 id="&#x5E03;&#x9686;&#x8FC7;&#x6EE4;&#x5668;">&#x5E03;&#x9686;&#x8FC7;&#x6EE4;&#x5668;</h4>
<p>&#x662F;&#x4E00;&#x79CD;&#x6570;&#x636E;&#x7ED3;&#x6784;</p>
<h4 id="&#x7F13;&#x5B58;&#x7A7A;&#x5BF9;&#x8C61;">&#x7F13;&#x5B58;&#x7A7A;&#x5BF9;&#x8C61;</h4>
<h3 id="&#x7F13;&#x5B58;&#x51FB;&#x7A7F;">&#x7F13;&#x5B58;&#x51FB;&#x7A7F;</h3>
<blockquote>
<p>&#x67E5;&#x8BE2;&#x91CF;&#x592A;&#x5927;&#xFF0C;&#x7F13;&#x5B58;&#x8FC7;&#x671F;</p>
</blockquote>
<h3 id="&#x7F13;&#x5B58;&#x96EA;&#x5D29;">&#x7F13;&#x5B58;&#x96EA;&#x5D29;</h3>
<blockquote>
<p>&#x7F13;&#x5B58;&#x96C6;&#x4E2D;&#x8FC7;&#x671F;&#x5931;&#x6548;&#xFF0C;Redis&#x5B95;&#x673A;</p>
</blockquote>

                                
                                </section>
                            
    </div>
    <div class="search-results">
        <div class="has-results">
            
            <h1 class="search-results-title"><span class='search-results-count'></span> results matching "<span class='search-query'></span>"</h1>
            <ul class="search-results-list"></ul>
            
        </div>
        <div class="no-results">
            
            <h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
            
        </div>
    </div>
</div>

                        </div>
                    </div>
                
            </div>

            
                
                <a href="MySQL.html" class="navigation navigation-prev " aria-label="Previous page: MySQL">
                    <i class="fa fa-angle-left"></i>
                </a>
                
                
                <a href="../数据结构知识/" class="navigation navigation-next " aria-label="Next page: 数据结构知识">
                    <i class="fa fa-angle-right"></i>
                </a>
                
            
        
    </div>

    <script>
        var gitbook = gitbook || [];
        gitbook.push(function() {
            gitbook.page.hasChanged({"page":{"title":"Redis","level":"1.11.3","depth":2,"next":{"title":"数据结构知识","level":"1.12","depth":1,"path":"数据结构知识/README.md","ref":"数据结构知识/README.md","articles":[{"title":"大话数据结构笔记1","level":"1.12.1","depth":2,"path":"数据结构知识/大话数据结构笔记1.md","ref":"数据结构知识/大话数据结构笔记1.md","articles":[]},{"title":"大话数据结构笔记2","level":"1.12.2","depth":2,"path":"数据结构知识/大话数据结构笔记2.md","ref":"数据结构知识/大话数据结构笔记2.md","articles":[]}]},"previous":{"title":"MySQL","level":"1.11.2","depth":2,"path":"数据库/MySQL.md","ref":"数据库/MySQL.md","articles":[]},"dir":"ltr"},"config":{"plugins":["-search","-lunr","-sharing","-anchor-navigation-ex","todo","code","-katex","github","-summary","search-pro","chapter-fold","theme-comscore","toggle-chapters","flexible-alerts"],"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"pluginsConfig":{"chapter-fold":{},"github":{"url":"https://github.com/BluePrintYang"},"todo":{},"search-pro":{},"code":{"copyButtons":true},"fontsettings":{"theme":"white","family":"sans","size":2},"highlight":{},"anchor-navigation-ex":{"showLevel":false,"showGoTop":true,"isRewritePageTitle":true,"isShowTocTitleIcon":true,"tocLevel1Icon":"fa fa-hand-o-right","tocLevel2Icon":"fa fa-hand-o-right","tocLevel3Icon":"fa fa-hand-o-right"},"theme-comscore":{},"flexible-alerts":{"danger":{"className":"danger","icon":"fa fa-ban","label":"Attention"},"note":{"className":"info","icon":"fa fa-info-circle","label":"Note"},"style":"callout","tip":{"className":"tip","icon":"fa fa-lightbulb-o","label":"Tip"},"warning":{"className":"warning","icon":"fa fa-exclamation-triangle","label":"Warning"}},"theme-default":{"styles":{"website":"styles/website.css","pdf":"styles/pdf.css","epub":"styles/epub.css","mobi":"styles/mobi.css","ebook":"styles/ebook.css","print":"styles/print.css"},"showLevel":false},"toggle-chapters":{}},"theme":"default","author":"yanglonglong","pdf":{"pageNumbers":true,"fontSize":12,"fontFamily":"Arial","paperSize":"a4","chapterMark":"pagebreak","pageBreaksBefore":"/","margin":{"right":62,"left":62,"top":56,"bottom":56}},"structure":{"langs":"LANGS.md","readme":"README.md","glossary":"GLOSSARY.md","summary":"SUMMARY.md"},"variables":{},"title":"My Study Note","language":"zh-hans","links":{"sidebar":{"My Blog":"https://www.yangllong.top/"}},"gitbook":"*"},"file":{"path":"数据库/Redis.md","mtime":"2020-07-03T09:18:10.000Z","type":"markdown"},"gitbook":{"version":"3.2.3","time":"2021-01-14T07:15:50.272Z"},"basePath":"..","book":{"language":""}});
        });
    </script>
</div>

        
    <script src="../gitbook/gitbook.js"></script>
    <script src="../gitbook/theme.js"></script>
    
        
        <script src="../gitbook/gitbook-plugin-code/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-github/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/jquery.mark.min.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-search-pro/search.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-chapter-fold/chapter-fold.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-toggle-chapters/toggle.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-flexible-alerts/plugin.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-fontsettings/fontsettings.js"></script>
        
    
        
        <script src="../gitbook/gitbook-plugin-theme-comscore/test.js"></script>
        
    

    </body>
</html>

